library pkg_dashedline_view;

import 'package:flutter/material.dart';

class Param {
  Axis axis;
  double dashedWidth;
  double dashedHeight;
  int count;
  Color color;
  Param(
      {this.axis = Axis.horizontal,
      this.color = Colors.black26,
      this.dashedHeight = 1,
      this.dashedWidth = 1,
      this.count = 10});
}

class DashLine extends StatelessWidget {
  late final Param param;

  DashLine({
    Axis? axis,
    double? dashedWidth,
    double? dashedHeight,
    int? count,
    Color? color,
  }) {
    param = Param(
        axis: axis ?? Axis.horizontal,
        color: color ?? Colors.black26,
        dashedHeight: dashedHeight ?? 1,
        dashedWidth: dashedWidth ?? 1,
        count: count ?? 10);
  }

  @override
  Widget build(BuildContext context) {
    return Flex(
      direction: param.axis,
//      这样才能铺开
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
//      用不上用_替代
      children: List.generate(param.count, (_) {
        return SizedBox(
            width: param.dashedWidth,
            height: param.dashedHeight,
//          这个东西是没有颜色的
            child: DecoratedBox(
              decoration: BoxDecoration(color: param.color),
            ));
      }),
    );
  }
}
